package main

import (
	"fmt"
	"time"
)

func main() {
	firstCh := make(chan string)
	secondCh := make(chan string)
	thirdCh := make(chan string)

	go func() {
		firstCh <- downloadFile("firstCh")
	}()
	go func() {
		secondCh <- downloadFile("secondCh")
	}()
	go func() {
		thirdCh <- downloadFile("thirdCh")
	}()

	select {
	case first := <-firstCh:
		fmt.Println(first)
	case second := <-secondCh:
		fmt.Println(second)
	case third := <-thirdCh:
		fmt.Println(third)
	}
}

func downloadFile(chanName string) string {

	// 模拟下载文件,可以自己随机time.Sleep点时间试试
	time.Sleep(time.Second)
	return chanName + ":filePath"
}
